cc.Class({
    extends: cc.Component,

    properties: {
        sprite: {
            default: null,      // The default value will be used only when the component attaching                               // to a node for the first time
            type: cc.Prefab,  // optional, default is typeof default
            serializable: true, // optional, default is true
            visible: true,      // optional, default is true
            displayName: 'sprite', // optional
            readonly: false,    // optional, default is false
        },
        // ...
        number: 100,
    },

    // use this for initialization
    onLoad: function () {
        this.follow();
        this.schedule(() =>{
            // 这里的 this 指向 component
            this.follow();
        }, 0.6);
    },

    follow() {
        for (let i = 0; i < this.number; i++) {
            let bullet=cc.instantiate(this.sprite)
            
            //获取脚本组件
            let comp = bullet.getComponent('bullet');
            comp.angle = Math.random() * Math.PI * 2;
            comp.velocity = 300;
            this.node.addChild(bullet);
        }
    }

    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {
    // },
});
